// 页面栈码
const state = {
  // 总码数
  count: 10,
  //需要从路由中提取的参数
  config: ['fullPath', 'name', 'params', 'query'],
  //页面堆
  page: []
}

const mutations = {
  /**
   * 路由设置
   */
  SET_PAGE: (state, payload) => {
    let stat = {}
    for (const key of state.config) {
      if (payload[key]) {
        stat[key] = payload[key]
      }
    }
    if (state.page?.length >= state.count) {
      state.page.shift()
    }
    state.page.push(stat)
    localStorage.setItem(`fiffion_${process.env.VUE_APP_VERSION}`, JSON.stringify(state.page))
  }
}

const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
